package com.hddx.Service;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

@Component
@Async
public class MyAspect {
    @Pointcut("execution(* com.hddx.Service.UserServicelmpl.*(..))")
    public void skip() {
    }

    @Before("skip()")
    public void before(JoinPoint point) {
        System.out.println("前置通知执行");
        System.out.println(point.getClass());
        System.out.println(point.getSignature().getName());
    }

    @After("skip()")
    public void after(JoinPoint point) {
        System.out.println("后置通知执行");
        System.out.println(point.getClass());
        System.out.println(point.getSignature().getName());
    }

    @Around("skip()")
    public Object around(ProceedingJoinPoint point) {
        System.out.println("1方法调用");
        Object proceed = null;
        try {
            proceed = point.proceed();
        } catch (Throwable throwable) {
            throwable.printStackTrace();
        }
        System.out.println("2方法调用");
        return proceed;
    }
    @AfterReturning("skip()")
    public void after_return(JoinPoint point){
        System.out.println("正常结束的后置通知执行");
    }
    @AfterThrowing("skip()")
    public void after_throw(JoinPoint poin){
        System.out.println("异常结束的后置通知执行");
    }

//public void before(){
//    System.out.println("请问签字/盖章用途是什么?");
//}
//public void after(){
//    System.out.println("事情已办妥，请问还有什么需要帮助的");
//}

        }
